﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using VIP.Domain.BusServices;
using VIP.Domain.DTO;
using VIP.Domain.VO;
using VIP.Infrastructure;

namespace VIP.Application.Controllers
{
    [ApiController]
    [Route("BaseData/[controller]")]
    public class OrderController : ControllerBase
    {
        private readonly IOrderService _orderService;
        public OrderController(IOrderService orderService)
        {
            _orderService = orderService;
        }
        /// <summary>
        /// 创建订单
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [Route("Create"), HttpPost]
        public Task<ApiResponse<OrderVO>> Create(CreateOrderDTO dto)
        {
            var rel = _orderService.Create(dto);
            return ApiRes.OKAsync(rel);
        }

        [Route("Create"), HttpPost]
        public Task<ApiResponse<Guid>> AddItem(Guid orderid, OrderItemDTO dto)
        {
            var rel = _orderService.AddItem(orderid, dto);
            return ApiRes.OKAsync(rel);
        }

        [Route("Query"), HttpPost]
        public Task<ApiResponse<OrderVO>> Query(string orderCode)
        {
            var rel = _orderService.Query(orderCode);
            return ApiRes.OKAsync(rel);
        }

    }
}
